'use strict';

module.exports = app => {
  const { INTEGER, STRING, DECIMAL, DATE } = app.Sequelize;

  const lendedInfo = app.model.define('LendedInfo', {
    id: {
      field: 'id',
      type: INTEGER,
      primaryKey: true,
    },
    bookId: {
      field: 'book_id',
      type: INTEGER,
    },
    userId: {
      field: 'user_id',
      type: INTEGER,
    },
    lendedDate: { field: 'lended_date', type: DATE, allowNull: true },
    returnDate: { field: 'return_date', type: DATE, allowNull: true },
    actualReturnDate: { field: 'actual_return_date', type: DATE, allowNull: true },
    broken: {
      type: INTEGER,
      defaultValue: 0
    },
    pay: {
      type: DECIMAL(5, 2),
      defaultValue: 0
    },
    createBy: { field: 'create_by', type: STRING(50), allowNull: true },
    createDate: { field: 'create_date', type: DATE, allowNull: true },
    updateBy: { field: 'update_by', type: STRING(50), allowNull: true },
    updateDate: { field: 'update_date', type: DATE, allowNull: true },
  },
    {
      timestamps: false,
      tableName: 'lended_info',
      created_at: false,
      updated_at: false,

    });

  return lendedInfo;
};

